package com.thb.pay.service;

import com.thb.pay.api.merchant.vo.resp.MchInfoVo;
import com.thb.pay.api.merchant.vo.resp.MchPayPassageVo;
import com.thb.pay.api.order.vo.req.PayOrderReq;
import com.thb.pay.api.payment.vo.resp.CurrencyTypeVo;
import com.thb.pay.api.payment.vo.resp.PayPassageAccountVo;
import com.thb.pay.core.utils.R;
import com.thb.pay.web.vo.CreateOrderVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description 订单服务
 * @Author lucky
 * @data 2019/10/19 15:02
 */
@Slf4j
@Component
public class OrderService extends BaseValidService {


    public R createOrder(CreateOrderVo createOrderVo) {

        return R.ok();
    }

    public PayOrderReq riskCheckReq(CreateOrderVo createOrderVo) {

        //1.商户规则校验
        MchInfoVo merchantInfo = this.validMerchant(createOrderVo.getMchId());
        //2.校验 appId
        this.validMerchantApp(createOrderVo.getAppId());
        //3.校验 产品ID
        this.validProduct(createOrderVo.getProductId());
        //4.校验 货币类型
        CurrencyTypeVo currencyTypeVo = this.validCurrency(createOrderVo.getCurrency());
        //5.校验 金额格式
        Long money = this.validMoney(createOrderVo.getMoney());
        //6.检验 并获取 商户对应产品ID 对应的支付通道配置
        MchPayPassageVo mchPayPassage = this.validMerchantPayPassage(createOrderVo.getMchId(), createOrderVo.getProductId());
        //7.获取支付通道账户 + 通道 风控校验
        PayPassageAccountVo payPassageAccount = this.getPayPassageAccount(mchPayPassage, currencyTypeVo, money, createOrderVo.getPayPassAccountId());
        //8.检查额外参数 特定通道有特定的规则约束

        PayOrderReq payOrderReq = new PayOrderReq();
        return null;
    }

}
